package com.ganzalang.gmall.promotion.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * @description: 满足促销活动的条件枚举类
 * @author: Ganzalang
 * @Date 2022/4/11 10:52
 */
@Getter
@AllArgsConstructor
public enum EnjoyConditionEnum{

    /**
     * 满额
     */
    FULL_AMOUNT(1, "满额"),
    /**
     * 满件
     */
    FULL_PIECE(2, "满件"),
    /**
     * 第N件
     */
    THE_N(3, "第N件"),
    /**
     * 满额且满件
     */
    FULL_AMOUNT_FULL_PIECE(4, "满额且满件");

    /**
     * 类型
     */
    private Integer type;
    /**
     * 中文描述
     */
    private String cnDesc;

    public static EnjoyConditionEnum valueOf(Integer type) {
        return Arrays.stream(EnjoyConditionEnum.values()).filter(item -> item.getType().equals(type)).findFirst().orElse(null);
    }
}
